<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

class IndexController extends Controller
{
    /**
     * 显示后台管理模板首页
     */
    public function index()
    {
        $user = Auth::guard('admin')->user();
        $role=$user->role;
        $menu_arr=[];
        foreach ($user->roles as $v) {
            if($v->menus && count($v->menus)>0){
                foreach ($v->menus as $m) {
                    $menu_arr[]=$m->menu_id;
                }
            }
        }
        if($user->menus && count($user->menus)>0){
            foreach($user->menus as $v){
                $menu_arr[]=$v->menu_id;
            }
        }
        // admin 显示所有
        // community_admin 控制显示
        // community_user 不显示
    	return view('admin.index')->with('role',$role)->with('menus',array_unique($menu_arr));
    }
    
    public function map()
    {
    	return redirect(route('admin_map'));
    }
}
